{% extends 'common/basic_layout.html' %}

{% block content %}

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{% block titleblock %}{% endblock %}
                        </h5>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal">
                            {% csrf_token %}
                            <input type="hidden" id="id" name="id" value="{{ pk }}"/>
                            {% for field in form %}
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"> {{ field.label_tag }}</label>
                                    <div class="col-sm-10">
                                        {{ field }}
                                        {{ field.errors }}
                                    </div>
                                </div>
                            {% endfor %}
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <a class="btn btn-white" href="javascript:history.go(-1)">取消</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function () {
            var fieldObj = $('.form-horizontal input')
            for (var i = 0; i < fieldObj.length; i++) {
                $(fieldObj[i]).addClass('form-control')
            }
            fieldObj = $('.form-horizontal textarea')
            for (var i = 0; i < fieldObj.length; i++) {
                $(fieldObj[i]).addClass('form-control')
            }

            fieldObj = $('.form-horizontal select')
            for (var i = 0; i < fieldObj.length; i++) {
                $(fieldObj[i]).addClass('form-control')
            }
        })

    </script>

{% endblock %}
